<?php
include "connect/connect_dsccmis.php";
mysql_query("set names utf8");
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
//XML Header
header("content-type:text/xml");
 // Selects all the rows in the markers table.
 $cond_date = "";
 $chkuse_date = $_GET["chkuse_date"];
 $date_start = $_GET["date_start"];
 $date_end = $_GET["date_end"];
 if($chkuse_date=="1"){
 	$cond_date = " and (evndte >= '".$date_start."' and evndte <= '".$date_end."')"; 
 }
 
 $cond_prov = "";
 $chkuse_prov = $_GET["chkuse_prov"];
 if($chkuse_prov=="1"){
 	$chkbox90 = $_GET["chkbox90"];
	$chkbox94 = $_GET["chkbox94"];
	$chkbox95 = $_GET["chkbox95"];
	$chkbox96 = $_GET["chkbox96"];
	if($chkbox90=="90") $cond_prov=$cond_prov.",'90'";
	if($chkbox94=="94") $cond_prov=$cond_prov.",'94'";
	if($chkbox95=="95") $cond_prov=$cond_prov.",'95'";
	if($chkbox96=="96") $cond_prov=$cond_prov.",'96'";
	$cond_prov=substr($cond_prov,1);
	$cond_prov=" and prov in (".$cond_prov.")";
 }

// event cause
 $cond_cause = $_GET["cond_cause"];
if($cond_cause!=""){
	$cond_cause = " and cdscc in ".$cond_cause;
}
// event type
 $cond_evntyp = $_GET["cond_evntyp"];
if($cond_evntyp!=""){
	$cond_evntyp = " and mis_evntypid in ".$cond_evntyp;
}

 $date_start = $_GET["date_start"];
 $date_end = $_GET["date_end"];


 $query = "select count(*) as c from gis_event where 1 ".$cond_date.$cond_prov.$cond_cause.$cond_evntyp;
 
 //echo $query;

 $result = mysql_query($query);
 if (!$result) 
 {
  die('Invalid query: ' . mysql_error());
 }else{
 	$row=mysql_fetch_array($result);
 	echo $row["c"];
 }
 mysql_close($c);
 
?>
